<template>
  <div>
    <div>
      <label>
        现有密码
        <input v-model="oldPassword" type="password" />
      </label>
    </div>
    <div>
      <label>
        密码
        <input v-model="newPassword" type="password" />
      </label>
    </div>
    <div>
      <label>
        确认密码
        <input v-model="confirmPassword" type="password" />
      </label>
    </div>
    <div>
      <button @click="save">提交</button>
    </div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      oldPassword: null,
      newPassword: null,
      confirmPassword: null
    };
  },
  methods: {
    save() {
      let data = new FormData();
      data.append("oldPassword", this.oldPassword);
      data.append("newPassword", this.newPassword);
      data.append("confirmPassword", this.confirmPassword);

      axios.post("/api/user-center/changePassword", data).then(response => {
        alert("密码修改成功");
      });
    }
  }
};
</script>
